<?php

use Illuminate\Support\Facades\Route;

//测试控制器
Route::get('/test',\App\Http\Controllers\TestController::class);

//测试
Route::get('/test',\App\Http\Controllers\TestController::class);

//首页
Route::get('/',[\App\Http\Controllers\IndexController::class,'index'])
    ->name('index');

//博客资源路由
Route::resource('/blog',\App\Http\Controllers\BlogController::class)
    ->except(['index']);


// 需要登录的页面
Route::middleware('auth')->group(function (){
    //登陆后，博客相关路由
    Route::prefix('blog')->name('blog.')->group(function (){
        //改变博客的状态  发布与不发布 部分资源路由
        Route::patch('/{blog}/status',[\App\Http\Controllers\BlogController::class,'status'])
            ->name('status');
        //评论
        Route::post('/{blog}/comment',\App\Http\Controllers\CommentController::class)
            ->name('comment');
    });

    //个人中心相关路由
    Route::prefix('user')->name('user.')->group(function (){
        //个人中心-修改个人信息-页面
        Route::get('/',[\App\Http\Controllers\UserController::class,'infoPage'])
            ->name('info');
        //个人中心-修改个人信息-更新数据
        Route::put('/',[\App\Http\Controllers\UserController::class,'infoUpdate'])
            ->name('info.update');

        //个人中心-更换头像-页面
        Route::get('/avatar',[\App\Http\Controllers\UserController::class,'avatarPage'])
            ->name('avatar');
        //个人中心-更换头像-更新数据
        Route::put('/avatar',[\App\Http\Controllers\UserController::class,'avatarUpdate'])
            ->name('avatar.update');

        //个人中心-我的博客
        Route::get('/blog',[\App\Http\Controllers\UserController::class,'blog'])
            ->name('blog');
    });
});





Route::middleware(['auth:sanctum', 'verified'])->get('/dashboard', function () {
    return view('dashboard');
})->name('dashboard');
